# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=git-warp-time
pkgver=0.7.6
pkgrel=0
pkgdesc="Reset timestamps of Git repository files to the time of the last modifying commit"
url="https://github.com/alerque/git-warp-time"
license="GPL-3.0-only"
arch="all"
makedepends="cargo cargo-auditable"
subpackages="$pkgname-bash-completion $pkgname-fish-completion $pkgname-zsh-completion"
options="net"
source="https://github.com/alerque/git-warp-time/archive/v$pkgver/git-warp-time-$pkgver.tar.gz"

prepare() {
	default_prepare

	# Doc-tests from README.md expect to be ran in a Git repository
	git init -q .
	git config --local user.name "example"
	git config --local user.email "example@example.com"
	git add .
	git commit -q -m "init"

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 target/release/$pkgname -t "$pkgdir"/usr/bin/

	# shell completions
	find target/release -name $pkgname.bash \
		-exec install -Dm644 {} "$pkgdir"/usr/share/bash-completion/completions/$pkgname \;
	find target/release -name $pkgname.fish \
		-exec install -Dm644 {} "$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish \;
	find target/release -name _$pkgname \
		-exec install -Dm644 {} "$pkgdir"/usr/share/zsh/site-functions/_$pkgname \;
}

sha512sums="
da5e13e9aa539e29fd246e3b08f2ab9539c14cd16515a3d152881c0999a2496b558e11876f7615c7e147c6096b3c7185c3330cd6e8374a1093d595cc8f5d7fdb  git-warp-time-0.7.6.tar.gz
"
